package com.akuma.swing;

import com.akuma.swing.plugin.ProjectWinPlugin;

import javax.swing.*;
import java.awt.*;

public class MyWindow extends JFrame {
    private Container con = this.getContentPane();
    JLabel main;

    MyWindow(String s) {
        super(s);
        Dimension screen = getToolkit().getScreenSize();  //得到屏幕尺寸
        this.setSize(800, 600);
        this.setLocation((screen.width - getSize().width) / 2, (screen.height - getSize().height) / 2); //设置窗口位置
        refresh();

        JButton jButton = new JButton("进入项目");
        ProjectWinPlugin.projectTable(800, 600, con, jButton);

        this.setVisible(true);
        this.setResizable(false);
        this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);  //关闭窗口时退出程序
    }

    private void refresh() {
        main = new JLabel();
        main.setSize(800, 600);
        con.add(main);
    }

    private void addProjects() {
        main = new JLabel();
        main.setSize(800, 600);
        con.add(main);
        addProjects();

        JLabel project = new JLabel("项目：");
        project.setSize(150, 30);
        project.setLocation(50, 0);
        main.add(project);
        ProjectWinPlugin.allSelect(200, 30, main, 100, 0);
    }

    public static void main(String[] args) {
        new MyWindow("Test");
    }
}